<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 主键
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $question_id 问题id
 * @property int $reply_id 回复id
 * @property int $sort 排序
 */
class ChSmartAnswerReplyQuestion extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_smart_answer_reply_question';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'created_at', 'updated_at', 'question_id', 'reply_id', 'sort'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'question_id' => 'integer', 'reply_id' => 'integer', 'sort' => 'integer'];

    public function question(){
        return $this->hasOne(ChSmartAnswerQuestion::class,'id','question_id');
    }
    public static function saveReplyQuestion($question_id,$reply_id,$sort)
    {
        $model=new self();
        $model->question_id=$question_id;
        $model->reply_id=$reply_id;
        $model->sort=$sort;
        $model->save();
        return $model;
    }
}
